#ifndef __AXIS_H
#define __AXIS_H

#include <stdio.h>
#include <string.h>
#include "motor.h"
#include "encoder.h"
#include "control.h"
#include "fault.h"

enum AxisState {
    AXIS_STATE_UNDEFINED                     = 0,   // 上电默认状态
    AXIS_STATE_IDLE                          = 1,   // 空闲状态
    AXIS_STATE_MOTOR_CALIBRATION             = 2,   // 相电流校准
    AXIS_STATE_CLOSED_LOOP_CONTROL           = 3,   // 闭环控制
    AXIS_STATE_ENCODER_OFFSET_CALIBRATION    = 4,   // 编码器偏移量
    AXIS_STATE_FAULT                         = 10,  // 故障状态
};

typedef struct _axis
{
    uint8_t current_state_;  // 状态
    uint8_t error_;          // 错误码

    motor_t motor;    
    encoder_t encoder;
    control_t control;
    fault_t fault;
}axis_t;

#endif
